package com.yuqian.JavaSe.sort;
/**
 * 冒泡排序
 * @author yy
 *
 */
public class BubblingSort {
	private static void swap(int[] arr,int indexA,int indexB) {
		int tem =arr[indexA];
		arr[indexA] = arr[indexB];
		arr[indexB] =tem;
	}
	
	public static void bubbling(int[] arr) {
		for(int i=0;i<arr.length;i++) {
			for(int j=0;j<arr.length-i-1;j++) {
				//前面一个大于后面一个则交换
				if(arr[j]>arr[j+1]) {
					swap(arr,j,j+1);
				}
			}
		}
	}
}
